﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Infrastructure.Web;
using VideoNet.Common;
using MyData.Dto;
using MyData.ApiDto;

namespace VideoNet.MyControls
{
    public partial class RecordUserControl : UserControl
    {
        public RecordUserControl()
        {
            InitializeComponent();
        }
        public void SetRefresh(Guid mobileId)
        {
            int j = 1;
            SynsInput synsOK = new SynsInput() { MobileId = mobileId };
            try
            {
                AjaxResult<List<RecentRecordDto>> recent = WWebClientHelper.HttpPost<AjaxResult<List<RecentRecordDto>>>(WWebClientHelper.RecentRecordApiString, WWebClientHelper.GetJson<SynsInput>(synsOK));
                var recentList = recent.data;
                foreach (var item in recentList)
                {

                    Control control = AutoSizeFormClass.findPicByName("pointLabel" + j, this.Controls);
                    if (control != null)
                        (control as Label).Visible = true;
                    Control control1 = AutoSizeFormClass.findPicByName("nameLabel" + j, this.Controls);
                    if (control1 != null)
                    {
                        (control1 as Label).Visible = true;
                        (control1 as Label).Text = item.Name;
                    }
                    Control control2 = AutoSizeFormClass.findPicByName("departLabel" + j, this.Controls);
                    if (control2 != null)
                    {
                        (control2 as Label).Visible = true;
                        (control2 as Label).Text = item.DepartName;
                    }
                    Control control3 = AutoSizeFormClass.findPicByName("timeLabel" + j, this.Controls);
                    if (control3 != null)
                    {
                        (control3 as Label).Visible = true;
                        (control3 as Label).Text = item.RecordTimeStr;
                    }
                    j++;
                }
                for (int t = j; t <= 8; t++)
                {
                    Control control = AutoSizeFormClass.findPicByName("pointLabel" + t, this.Controls);
                    if (control != null)
                        (control as Label).Visible = false;
                    Control control1 = AutoSizeFormClass.findPicByName("nameLabel" + t, this.Controls);
                    if (control1 != null)
                    {
                        (control1 as Label).Visible = false;

                    }
                    Control control2 = AutoSizeFormClass.findPicByName("departLabel" + t, this.Controls);
                    if (control2 != null)
                    {
                        (control2 as Label).Visible = false;
                    }
                    Control control3 = AutoSizeFormClass.findPicByName("timeLabel" + t, this.Controls);
                    if (control3 != null)
                    {
                        (control3 as Label).Visible = false;
                    }
                }
           
            }
            catch (Exception ex)
            {

              
            }
        }
    }
}
